package com.cloudfun.campusshare.entity;

import com.cloudfun.campusshare.common.constant.AttachType;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * 附件表
 *
 * @author linyangping
 * @create 2019-11-16 下午2:00
 **/
@Data
@Entity
@NoArgsConstructor
@Table(name = "attachment")
public class AttachmentEntity extends BaseEntity {

    @Id
    @GenericGenerator(name = "id_uuid", strategy = "uuid")
    @GeneratedValue(generator = "id_uuid")
    @Column(name = "id", nullable = false, unique = true, length = 40)
    private String id;

    @Column(name = "bucket_name", columnDefinition = ("varchar(255) not null comment '附件桶名称'"))
    private String bucketName;

    @Column(name = "file_hash", columnDefinition = ("varchar(66) not null comment '文件内容hash'"))
    private String fileHash;

    @Column(name = "trans_hash", columnDefinition = ("varchar(66) default null comment '交易hash'"))
    private String transHash;

    @Column(name = "url", columnDefinition = ("varchar(500) default null comment '附件url地址'"))
    private String url;

    @Column(name = "count", columnDefinition = ("int(11) default 0 comment '附件存储次数'"))
    private Integer count;

    @Column(name = "subject_id", columnDefinition = ("varchar(40) default null comment '附件所属主体Id'"))
    private String subjectId;

    @Column(name = "type", columnDefinition = ("varchar(32) not null comment '附件类型'"))
    @Enumerated(EnumType.STRING)
    private AttachType type;

    @Column(name = "name", columnDefinition = ("varchar(200) not null comment '附件名称'"))
    private String name;

    @Column(name = "obj_name", columnDefinition = ("varchar(256) not null comment 'OSS上的对象名'"))
    private String objName;

}